package com.aegean.MonitorExamSYS.center.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

@Controller("ConfirmConductionState")
@Scope("prototype")
public class ConfirmConductionState extends ActionSupport implements
		ServletRequestAware {
	private Map<Integer, Integer> con_PositionCountMap;
	private HttpSession session;
	private HttpServletRequest request;
	private int conduction_Id;
	private int personCount;
	private boolean success;

	public int getConduction_Id() {
		return conduction_Id;
	}

	public void setConduction_Id(int conduction_Id) {
		this.conduction_Id = conduction_Id;
	}

	public int getPersonCount() {
		return personCount;
	}

	public void setPersonCount(int personCount) {
		this.personCount = personCount;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub

		con_PositionCountMap = (Map<Integer, Integer>) session
				.getAttribute("confirmPositionPersonCount");// 确定考点人数的确定
		if (con_PositionCountMap == null) {
			success = false;
			personCount = 0;
		} else {
			success = con_PositionCountMap.containsKey(conduction_Id);
			if (success == false) {
				personCount = 0;
			} else {
				personCount = con_PositionCountMap.get(conduction_Id);
			}
		}
		return SUCCESS;
	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		request = arg0;
		session = request.getSession();

	}
}
